package everyday;

import org.junit.jupiter.api.Test;
import tool.s;

public class T2409 {
    int[] days = new int[]{0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30};
    public int countDaysTogether(String arriveAlice, String leaveAlice, String arriveBob, String leaveBob) {
        for (int i = 1; i < days.length; i++) days[i] += days[i - 1];
        int arriveA = getDays(arriveAlice), leaveA = getDays(leaveAlice);
        int arriveB = getDays(arriveBob), leaveB = getDays(leaveBob);
        if (arriveA > leaveB || arriveB > leaveA) return 0;
        return Math.min(leaveA, leaveB) - Math.max(arriveA, arriveB) + 1;
    }

    public int getDays(String string) {
        return days[Integer.parseInt(string.substring(0, 2)) - 1] + Integer.parseInt(string.substring(3, 5));
    }

    @Test
    public void test() {
        System.out.println(countDaysTogether("10-01", "10-31", "11-01", "12-31"));

    }
}
